package cn.dgiot.fd.model;

import java.sql.Timestamp;
import java.util.List;

import com.aliyun.oss.common.utils.StringUtils;

/**
 * [远程参数设置]
 * @author
 *
 */
public class PropertiesSetModel extends BaseModel{

	/** 配置地址 */   
	private String configurationAddress;
	/** 透明传输 */ 
	private String transparentTransmission;
	/** 心跳间隔 */ 
	private String heartbeatInterval;
	/** 浮冲电压 */
	private String floatingImpulseVoltage;
	/** 开关量 */
	private String switchingValue;
	/** 485波特率  */ 
	private String baudRate485;
	/** 485数据位  */ 
	private String dataBits485;
	/** 485停止位    */ 
	private String stopBit485;
	/** 485校验位    */ 
	private String checkBit485;
	/** 232波特率  */ 
	private String baudRate232;
	/** 232数据位    */ 
	private String dataBits232;
	/** 232停止位    */ 
	private String stopBit232;
	/** 232校验位    */ 
	private String checkBit232;
	/** id */
	private String id;
	/** 设备id */
	private String iotId;
	/** 升级任务id */
	private String messageId;
	/** 升级状态 */
	private String status;
	/** 版本 */
	private String version;
	/** 创建时间 */
	private Timestamp createTime;
	/** 反馈时间 */
	private Timestamp responseTime;

	private List<String> deviceNames;
	
	public PropertiesSetModel() {
		
	}
	
	public PropertiesSetModel(String deviceName, String productKey) {
		this.setDeviceName(deviceName);
		this.setProductKey(productKey);
	}
	
	public PropertiesSetModel(PropertiesSetFlowModel propertiesSetFlowModel) {
		this.setMessageId(propertiesSetFlowModel.getMessageId());
		this.setStatus(propertiesSetFlowModel.getStatus());
		this.setCreateTime(propertiesSetFlowModel.getCreateTime());
		this.setDeviceNames(propertiesSetFlowModel.getDeviceNames());
		this.setProductKey(propertiesSetFlowModel.getProductKey());
	}
	
	public String getConfigurationAddress() {
		return configurationAddress;
	}
	public void setConfigurationAddress(String configurationAddress) {
		this.configurationAddress = configurationAddress;
	}
	public String getTransparentTransmission() {
		return transparentTransmission;
	}
	public void setTransparentTransmission(String transparentTransmission) {
		this.transparentTransmission = transparentTransmission;
	}
	public String getHeartbeatInterval() {
		return heartbeatInterval;
	}
	public void setHeartbeatInterval(String heartbeatInterval) {
		this.heartbeatInterval = heartbeatInterval;
	}
	public String getBaudRate485() {
		return baudRate485;
	}
	public void setBaudRate485(String baudRate485) {
		this.baudRate485 = baudRate485;
	}
	public String getDataBits485() {
		return dataBits485;
	}
	public void setDataBits485(String dataBits485) {
		this.dataBits485 = dataBits485;
	}
	public String getStopBit485() {
		return stopBit485;
	}
	public void setStopBit485(String stopBit485) {
		this.stopBit485 = stopBit485;
	}
	public String getCheckBit485() {
		return checkBit485;
	}
	public void setCheckBit485(String checkBit485) {
		this.checkBit485 = checkBit485;
	}
	public String getBaudRate232() {
		return baudRate232;
	}
	public void setBaudRate232(String baudRate232) {
		this.baudRate232 = baudRate232;
	}
	public String getDataBits232() {
		return dataBits232;
	}
	public void setDataBits232(String dataBits232) {
		this.dataBits232 = dataBits232;
	}
	public String getStopBit232() {
		return stopBit232;
	}
	public void setStopBit232(String stopBit232) {
		this.stopBit232 = stopBit232;
	}
	public String getCheckBit232() {
		return checkBit232;
	}
	public void setCheckBit232(String checkBit232) {
		this.checkBit232 = checkBit232;
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getIotId() {
		return iotId;
	}

	public void setIotId(String iotId) {
		this.iotId = iotId;
	}

	public String getMessageId() {
		return messageId;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	public Timestamp getResponseTime() {
		return responseTime;
	}

	public void setResponseTime(Timestamp responseTime) {
		this.responseTime = responseTime;
	}

	public List<String> getDeviceNames() {
		return deviceNames;
	}

	public void setDeviceNames(List<String> deviceNames) {
		this.deviceNames = deviceNames;
	}

	public String toJSON() {
		StringBuilder jsonV = new StringBuilder();
		boolean flag = false;
		jsonV.append("{");
		/** 配置地址 */   
		if(!StringUtils.isNullOrEmpty(configurationAddress)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"ConfigurationAddress\":");
			jsonV.append("\""+configurationAddress+"\"");
		}
		/** 透明传输 */ 
		if(!StringUtils.isNullOrEmpty(transparentTransmission)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"TransparentTransmission\":");
			jsonV.append(transparentTransmission);
		}
		/** 心跳间隔 */ 
		if(!StringUtils.isNullOrEmpty(heartbeatInterval)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"HeartbeatInterval\":");
			jsonV.append(heartbeatInterval);
		}
		/** 485波特率  */ 
		if(!StringUtils.isNullOrEmpty(baudRate485)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"BaudRate485\":");
			jsonV.append(baudRate485);
		}
		/** 485数据位  */ 
		if(!StringUtils.isNullOrEmpty(dataBits485)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"DataBits485\":");
			jsonV.append(dataBits485);
		}
		/** 485停止位    */ 
		if(!StringUtils.isNullOrEmpty(stopBit485)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"StopBit485\":");
			jsonV.append(stopBit485);
		}
		/** 485校验位    */ 
		if(!StringUtils.isNullOrEmpty(checkBit485)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"CheckBit485\":");
			jsonV.append(checkBit485);
		}
		/** 232波特率  */ 
		if(!StringUtils.isNullOrEmpty(baudRate232)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"BaudRate232\":");
			jsonV.append(baudRate232);
		}
		/** 232数据位    */ 
		if(!StringUtils.isNullOrEmpty(dataBits232)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"DataBits232\":");
			jsonV.append(dataBits232);
		}
		/** 232停止位    */ 
		if(!StringUtils.isNullOrEmpty(stopBit232)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"StopBit232\":");
			jsonV.append(stopBit232);
		}
		/** 232校验位    */ 
		if(!StringUtils.isNullOrEmpty(checkBit232)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"CheckBit232\":");
			jsonV.append(checkBit232);
		}
		/** 浮冲电压    */ 
		if(!StringUtils.isNullOrEmpty(floatingImpulseVoltage)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"FloatingImpulseVoltage\":");
			jsonV.append("\""+floatingImpulseVoltage+"\"");
		}
		/** 开关量  */ 
		if(!StringUtils.isNullOrEmpty(switchingValue)){
			if(flag) {
				jsonV.append(",");
			}
			flag =true;
			jsonV.append("\"SwitchingValue\":");
			jsonV.append("\""+switchingValue+"\"");
		}
		jsonV.append("}");
		return jsonV.toString();
	}
	
}
